﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using SDFL.Helper;

namespace SDFL.Tools.WeatherLib
{
    public class CityXmlInfo
    {
        public const string __City = "city";
        public const string __Name = "name";
        public const string __Code = "code";

        public string Name { get; set; }
        public string Code { get; set; }

        public XmlNode ToXmlNode(XmlDocument document)
        {
            var node = XMLHelper.CreateXmlNode(document, __City);
            XMLHelper.SetAttributeValue(node, __Name, this.Name);
            XMLHelper.SetAttributeValue(node, __Code, this.Code);
            return node;
        }
        public void Read(XmlNode node)
        {
            this.Name = XMLHelper.GetAttributeValue<string>(node, __Name, string.Empty);
            this.Code = XMLHelper.GetAttributeValue<string>(node, __Code, string.Empty);
        }
    }
}
